package top.laoshuzi.mvp.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.alibaba.android.arouter.launcher.ARouter;

import top.laoshuzi.android.mvp.MVP;
import top.laoshuzi.android.mvp.view.MVPBinder;

public abstract class BaseActivity extends AppCompatActivity implements Injectable {

    MVPBinder mvpBinder;

    public BaseActivity() {
        ARouter.getInstance().inject(injectObject());
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mvpBinder = MVP.bind(injectObject());
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mvpBinder != null)
            mvpBinder.unbind();
    }

}
